package adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.newxlmedical.R;

import java.util.List;

import beans.StorageWarningInfoBean;
import butterknife.BindView;
import butterknife.ButterKnife;
import custom.BaseRecyclerAdapter;

/**
 * Created by Administrator on 2018/5/7.
 */

public class InventoryListViewAdapter extends BaseRecyclerAdapter<InventoryListViewAdapter.WaringViewHolder> {
    @BindView(R.id.inventory_list_goods)
    TextView inventoryListGoods;
    @BindView(R.id.inventory_list_size)
    TextView inventoryListSize;
    @BindView(R.id.inventory_list_supplier)
    TextView inventoryListSupplier;
    @BindView(R.id.inventory_list_surplus)
    TextView inventoryListSurplus;
    @BindView(R.id.inventory_list_prewarning)
    TextView inventoryListPrewarning;
    @BindView(R.id.inventory_list_rl)
    RelativeLayout inventoryListRl;
    private LayoutInflater inflater;
    private List<StorageWarningInfoBean> list;
//    private OnClickListener onClickListener;

    public InventoryListViewAdapter(Context mContext, List<StorageWarningInfoBean> list) {
        this.inflater = LayoutInflater.from(mContext);
        this.list = list;
    }

    @Override
    public WaringViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        WaringViewHolder waringHolder = new WaringViewHolder(inflater.inflate(R.layout.inventory_listview, parent, false));

        return waringHolder;
    }

    @Override
    public void onBindViewHolder(final WaringViewHolder viewHolder, final int position) {
        StorageWarningInfoBean bean = list.get(position);
        viewHolder.inventoryListGoods.setText(bean.getGoodsName());
        viewHolder.inventoryListSize.setText(bean.getSpecification());
        viewHolder.inventoryListSupplier.setText(bean.getSupplier());
        viewHolder.inventoryListSurplus.setText(bean.getNumber());
        viewHolder.inventoryListPrewarning.setText(bean.getWarnCount());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class WaringViewHolder extends BaseRecyclerAdapter.BaseViewHolder {
        @BindView(R.id.inventory_list_goods)
        TextView inventoryListGoods;
        @BindView(R.id.inventory_list_size)
        TextView inventoryListSize;
        @BindView(R.id.inventory_list_supplier)
        TextView inventoryListSupplier;
        @BindView(R.id.inventory_list_surplus)
        TextView inventoryListSurplus;
        @BindView(R.id.inventory_list_prewarning)
        TextView inventoryListPrewarning;
        @BindView(R.id.inventory_list_rl)
        RelativeLayout inventoryListRl;

        public WaringViewHolder(View itemView) {
            super(itemView);
        }
    }

//    public void setOnClickListener(OnClickListener onClickListener) {
//        this.onClickListener = onClickListener;
//    }
//
//    public interface OnClickListener {
//        //        void onShowDetailSpecification(int position, TextView view);
//        void onShowDetail(int position, TextView view,int xOffWidth);
//        //        void onShowDetailSupplier(int position, TextView view);
//    }
}
